package com.example.cola.domain.model;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户状态枚举
 * 
 * @author 资深开发专家
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum UserStatus {
    
    ENABLED(1, "启用"),
    DISABLED(0, "禁用");
    
    private final Integer code;
    private final String description;
    
    public static UserStatus fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        
        for (UserStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        
        throw new IllegalArgumentException("无效的用户状态码: " + code);
    }
    
    public boolean isEnabled() {
        return this == ENABLED;
    }
    
    public boolean isDisabled() {
        return this == DISABLED;
    }
}
